package com.woniuxy.jwt;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @author: zhouhongcheng
 * Date: 2022/2/22:19:26
 * Description:解析jwt字符串 Authorization
 */
public class ParseJwt {
    public static void main(String[] args) {
        String token="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4ODgiLCJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NTUzMDg3MywiZXhwIjoxNjQ1NTMwOTMzLCJ1c2VybmFtZSI6Im1heXVoYW5nIiwicGFzc3dvcmQiOjEyMzQ1Nn0.foS95uIJRjxvQMgmCweIuYAQu_Ws3xd_uB71u5uAJ-Q";
        Claims claims = Jwts.parser().setSigningKey("woniuxy").parseClaimsJws(token).getBody();
        System.out.println(claims.getId());
        System.out.println(claims.getSubject());
        System.out.println(claims.getIssuedAt());
        System.out.println(claims.get("username"));
        System.out.println(claims.get("password"));
    }
}
